/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Model;

import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.image.BufferedImage;

/**
 *
 * @author PhucAnh
 */
public class MyObject {
    Shape[] obj;
    int n;

    public MyObject() {
        n= 0;
    }

    public MyObject(Shape[] obj, int n) {
        this.obj = obj;
        this.n = n;
    }

    public Shape[] getObj() {
        return obj;
    }

    public void setObj(Shape[] obj) {
        this.obj = obj;
    }

    public int getN() {
        return n;
    }

    public void setN(int n) {
        this.n = n;
    }
    public void addShape(Shape sh)
    {
        if(n==0)
        {
            obj=new Shape[1];
            obj[n]=sh;
            n++;
        }
        else
        {
        Shape[] temp = new Shape[n+1];
        for(int i=0;i<n;i++) {
                temp[i] = obj[i];
            }
        temp[n]= sh;
        obj= new Shape[n+1];
        obj = temp;
        n++;
        }
    }
    public void deleteShape()
    {
        if(n>0)
        {
            n--;
        }
    }
    public void drawObj(Graphics g2,BufferedImage img)
    {
        Graphics2D g = (Graphics2D) g2;
        for(int i = 0;i<this.getN();i++)
        {
            this.getObj()[i].drawShape(g2,img);
        }
    }

}
